﻿@using System.Web.Mvc.Html
@model LanShellManager.Models.ShellCommandRunVm
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Run shell command on a machine</h2>
@{
    List<SelectListItem> machines = new List<SelectListItem>();
    List<SelectListItem> shellCommands = new List<SelectListItem>();
    foreach (var machine in Model.Machines)
    {
        machines.Add(new SelectListItem
        {
            Text = machine.Name,
            Value = machine.Name
        });
    }    
    
    foreach (var shellCommand in Model.ShelllCommands)
    {
        shellCommands.Add(new SelectListItem
        {
            Text = shellCommand.Text,
            Value = shellCommand.Text
        });
    }
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        <hr/>

        @Html.ValidationSummary(true)

        <div class="form-group">
            @Html.Label("Machine Name", new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.DropDownListFor(m => m.Machines, machines, "-- Select Machine --")

            </div>
        </div>

        <div class="form-group">
            @Html.Label("Shell Command", new {@class = "control-label col-md-2"})
            <div class="col-md-10">
                @Html.DropDownListFor(m => m.ShelllCommands, shellCommands, "-- Select Command --")
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Run Command" class="btn btn-default"/>
            </div>
        </div>
    </div>
}

